using System;
using System.Collections.Generic;
using DecisionMaking.Domain;
namespace DecisionMaking.BusinessLogic
{
	/// <summary>
	/// Encapsulates the strategy for executing a decision-making algorithm 
	/// </summary>
	public interface IAlgorithm
	{
	    /// <summary>
	    /// Executes the specified algorithm, returning an AlgorithmResult struct. This struct encapsulated 3 result values: 
	    /// * Result: the decision made (negative for the left candidate, positive for the right candidate, 0 when could not decide)
	    /// * CuesUsed: the number of cues used until a decision was made
	    /// * Candidates recognized: whether the agent recognized none of the candidates, only one of them or both of them.
	    /// </summary>
	    /// <param name="agent"></param>
	    /// <param name="cues"></param>
	    /// <param name="left"></param>
	    /// <param name="right"></param>
	    /// <returns></returns>
	    AlgorithmResult Execute(Agent agent,  IList<Cue> cues, Candidate left, Candidate right);

        /// <summary>
        /// Validates the algorithm code; if validation passes, returns null, otherwise returns an error message
        /// </summary>
        /// <returns></returns>
	    string Validate();
		
		AlgorithmDefinition GetDefinition();

	    void SetDefinition(AlgorithmDefinition definition);
	}

    /// <summary>
    /// The result of a single algorithm execution
    /// </summary>
    public struct AlgorithmResult
    {
        public short Result;
        public short CuesUsed;
        public short CandidatesRecognized;

        public AlgorithmResult(short result, short cuesUsed, short candidatesRecognized)
        {
            Result = result;
            CuesUsed = cuesUsed;
            CandidatesRecognized = candidatesRecognized;
        }
    }
}

